package tech.aistar.day01;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 本类用来演示: 转发和重定向
 *
 * @author: success
 * @date: 2021/4/15 1:38 下午
 */
@WebServlet(urlPatterns = "/day02/forward/to")//模糊匹配<精确匹配
public class ForwardToDemo extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();

        //从request作用域中去获取数据
        String username = (String) req.getAttribute("username");
        out.println("to..."+username);
    }
}
